#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int w, s;
string code;
enum STATE { HIG, LOW, NUM };

const int MOD = 929;

int main() {
  cin >> w >> s;
  cin >> code;

  vector<int> seq;
  vector<int> ma;

  STATE state = HIG;
  for(char c : code) {
    if (isdigit(c)) {
      if (state != NUM) seq.push_back(28);
      seq.push_back(c - '0');
      state = NUM;
    } else if (isupper(c)) {
      if (state != HIG) seq.push_back(28);
      if (state == LOW) seq.push_back(28);
      seq.push_back(c - 'A');
      state = HIG;
    } else if (islower(c)) {
      if (state != LOW) seq.push_back(27);
      seq.push_back(c - 'a');
      state = LOW;
    }
  }
  if (seq.size() % 2) seq.push_back(29);
  for (int i = 0; i < seq.size(); i += 2)
    ma.push_back(seq[i] * 30 + seq[i + 1]);

  if (s == -1) {
    int n = ma.size() + 1;

    while (n % w) {
      ma.push_back(900);
      n++;
    }
    ma.insert(ma.begin(), n);
    for (auto i : ma) {
      cout << i << endl;
    }
  } else {
    int k = 1 << (s + 1);
    int n = ma.size() + 1 + k;
    while (n % w) {
      n++;
      ma.push_back(900);
    }
    n -= k;
    ma.insert(ma.begin(), n);

    vector<ll> dx(n + k, 0);
    vector<ll> gx(n + k, 0);

    for (int i = 0; i <= n - 1; ++i) {
      dx[n + k - 1 - i] = ma[i] % MOD;
    }

    gx[0] = 1;
    int g_top = 0;
    int exp = 1;
    vector<int> mul(2);
    mul[1] = 1;
    for (int i = 0; i < k; ++i) {
      vector<ll> tmp(n + k, 0);
      exp = (exp * 3) % MOD;
      mul[0] = -exp;
      for (int j = 0; j <= g_top; ++j)
        for (int l = 0; l <= 1; ++l) {
          tmp[j + l] =
              (tmp[j + l] % MOD + (gx[j] % MOD) * (mul[l] % MOD)) % MOD;
        }
      gx = tmp;
      g_top += 1;
    }

    int d_top = n + k - 1;
    while (d_top >= k) {
      int div = dx[d_top] / gx[g_top];
      for (int i = 0; i <= g_top; ++i) {
        dx[d_top - i] =
            ((dx[d_top - i] % MOD) - (div % MOD) * (gx[g_top - i] % MOD)) % MOD;
      }
      d_top--;
    }

    for (int i = k - 1; i >= 0; --i) {
      ma.push_back(((-dx[i] % MOD) + MOD) % MOD);
    }
    for (auto i : ma) {
      cout << i << endl;
    }
  }
  return 0;
}
